package me.pinion.kit;

import me.pinion.Log;
import me.pinion.XTimeConfig;
import org.apache.commons.codec.digest.DigestUtils;

import java.io.UnsupportedEncodingException;


public class CommonKit {
    public static String encrypt(String origin){
        return DigestUtils.md5Hex(origin.substring(0, 3) + origin.substring(1, 4) + origin.substring(2));
    }

    public static String urlVal2utf8(String param){
        String newStr;
        switch (XTimeConfig.OS_NAME){
            case LINUX:
                newStr = param;
                break;
            default:
                try {
                    newStr = new String(param.getBytes("ISO-8859-1"), "UTF-8");
                } catch (UnsupportedEncodingException e) {
                    Log.e(e);
                    newStr = param;
                }
                break;
        }
        Log.i(newStr);
        return newStr;
    }
}
